import os
from threading import Thread

class DownloadGroup(Thread):
	def __init__(self, downloads):
		Thread.__init__(self)
		self.downloads = []
		self.downloads = downloads
		
	def run(self):
		totalbytes = 0
		for download in self.downloads:
			download.start()
			totalbytes += download.totalbytes
				
		while 1:
			os.system('cls')
			bytesread = 0
			for download in self.downloads:
				bytesread += download.bytesread
			print 'Downloaded %d bytes from %d' % (bytesread, totalbytes)
			
			if not any(download.isAlive() for download in self.downloads):
				break
			
			#if bytesread >= totalbytes:
			#	break